<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
	<meta name="description" content="我的账本增加消费类型">

	<link rel="stylesheet" href="../weui/lib/weui.min.css">
	<link rel="stylesheet" href="../weui/css/jquery-weui.css">
	<link rel="stylesheet" href="../css/Gstyle.css">

	<title>个人中心-我的账本</title>
</head>
<body>
<div class="weui-tab">

	<div class="weui-tab__bd">
		<header class='login-header'>
			<h1 class="login-title">
				<div style="width:50px; height:50px; background-color:#9ED99D; border-radius:25px;margin: 0 auto;">
					<span style="height:50px; line-height:50px; display:block; color:#FFF; text-align:center;">策</span>
				</div>
			</h1>
		</header>

		<div class="weui-form-preview">
			<div class="weui-form-preview__hd">
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label" style="color: #10AEFF;">上周花费</label>
					<em class="weui-form-preview__value" id="sWeek">¥0.00</em>
				</div>
			</div>

			<div class="weui-form-preview__hd">
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label" style="color: #EC8B89;">本周花费</label>
					<em class="weui-form-preview__value" id="bWeek">¥0.00</em>
				</div>
			</div>
			<div class="weui-form-preview__hd">
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label" style="color: #10AEFF;">上月花费</label>
					<em class="weui-form-preview__value" id="sMonth">¥0.00</em>
				</div>
			</div>
			<div class="weui-form-preview__hd">
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label" style="color: #EC8B89;">本月花费</label>
					<em class="weui-form-preview__value" id="bMonth">¥0.00</em>
				</div>
			</div>
		</div>

		<div class="weui-footer weui-footer_fixed-bottom">
			<a href="javascript:;" class="weui-btn weui-btn_warn" style="color: #FFFFFF;">退出</a>
		</div>
	</div>

	<div class="weui-tabbar">
		<a  class="weui-tabbar__item " href="./index.html">
			<div class="weui-tabbar__icon">
				<img src="../img/icon_nav_msg.png" alt="">
			</div>
			<p class="weui-tabbar__label">增加记录</p>
		</a>
		<!--<a class="weui-tabbar__item " href="addtype.html">
			<div class="weui-tabbar__icon">
				<img src="../img/icon_nav_article.png" alt="">
			</div>
			<p class="weui-tabbar__label">增加类型</p>
		</a>-->
		<a href="./showitem.html" class="weui-tabbar__item" >
			<div class="weui-tabbar__icon">
				<img src="../img/icon_nav_search_bar.png" alt="">
			</div>
			<p class="weui-tabbar__label">查看消费</p>
		</a>
		<a href="./setting.html" class="weui-tabbar__item weui-bar__item--on">
			<div class="weui-tabbar__icon">
				<img src="../img/icon_nav_button.png" alt="">
			</div>
			<p class="weui-tabbar__label">设置</p>
		</a>
	</div>
</div>
<script src="../weui/lib/jquery-2.1.4.js"></script>
<!--<script src="../weui/lib/fastclick.js"></script>-->
<script src="../weui/js/jquery-weui.js"></script>
<script type="text/javascript" src="../weui/lib/weui.min.js"></script>
<script>
    var addhistory=JSON.parse(window.localStorage.getItem('consume'))||[];
    if(addhistory.length==0){
        $('#consume').html('<div></div>')
        $.notification({
            title: "暂无消费/收入记录",
            time:1000,
        });
    }else {
        var d = new Date();
        var str = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes();
        var date = new Date(str);
        var time1 = date.getTime()/1000;
        console.log(time1)
		var sWeek=0;
		var bWeek=0;
		var sMonth=0;
		var bMonth=0;
        for(var i=addhistory.length-1;i>=0;i--){
            var time2= new Date(addhistory[i].time).getTime()/1000;
            var chaTime=7*24*60*60;
            var chaTime2=7*24*60*60*2;
            var chaTime3=7*24*60*60*4;
            if((time1-time2)<chaTime){
                bWeek+=parseFloat(addhistory[i].addMoney)
			}
			if((time1-time2)>chaTime&&(time1-time2)<chaTime2){
                sWeek+=parseFloat(addhistory[i].addMoney)
			}
            if((time1-time2)<chaTime3){
                bMonth+=parseFloat(addhistory[i].addMoney)
            }
            if((time1-time2)>chaTime3){
                sMonth+=parseFloat(addhistory[i].addMoney)
            }
        }
        $('#bWeek').text(bWeek.toFixed(2))
        $('#sWeek').text(sWeek.toFixed(2))
        $('#bMonth').text(bMonth.toFixed(2))
        $('#sMonth').text(sMonth.toFixed(2))

    }
</script>

</body>
</html>





